QString conn = "ens37"; QProcess statusProc; statusProc.start("nmcli", QStringList() << "-t" << "-f" << "NAME,STATE" << "connection" << "show" << "--active"); statusProc.waitForFinished(); QString statusOutput = statusProc.readAllStandardOutput(); QStringList activeConnections = statusOutput.split("
", Qt::SkipEmptyParts); bool wasConnected = false; for (const QString &line : activeConnections) { QStringList parts = line.split(":"); if (parts.size() == 2 && parts[0] == conn) { wasConnected = true; break; } } printf("ens37 wasConnected: %d
", wasConnected);
